package chat.server.gui;

import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class ServerStatusInformationGUI extends JPanel {

	GridLayout layout = new GridLayout(2,2);
	JLabel id = new JLabel("ID: ");
	JLabel name = new JLabel("Name: ");
	JLabel member = new JLabel("Mitglieder: ");
	JLabel editable = new JLabel("Editierbar: ");
	
	/**
	 * Konstruktor
	 */
	public ServerStatusInformationGUI() {
		
		setLayout(layout);
		buildGUI();
		
	}
	
	/**
	 * baut GUI auf
	 */
	private void buildGUI() {
		add(id);
		add(name);
		add(member);
		add(editable);
	}
	
	/**
	 * aktualisiert ID
	 * @param id
	 */
	public void updateID(int id) {
		this.id.setName("ID: " + String.valueOf(id));
	}
	
	/**
	 * aktualisiert Namen
	 * @param name
	 */
	public void updateName(String name) {
		this.name.setName("Name: " + String.valueOf(id));
	}
	
	/**
	 * aktualisiert Anzahl der Mitglieder
	 * @param numberOfMembers
	 */
	public void updateMember(int numberOfMembers) {
		this.member.setName("Mitglieder: " + String.valueOf(numberOfMembers));
	}
	
	/**
	 * aktualisiert Editierbarkeit
	 * @param editable
	 */
	public void updateEditable(boolean editable) {
		if(editable)
			this.editable.setName("Editierbar: ja");
		else
			this.editable.setName("Editierbar: nein");
	}
	
	/**
	 * aktualisiert alles
	 * @param id
	 * @param name
	 * @param numberOfMembers
	 * @param editable
	 */
	public void updateAll(int id, String name, int numberOfMembers, boolean editable) {
		updateID(id);
		updateName(name);
		updateMember(numberOfMembers);
		updateEditable(editable);
	}
	
}
